<html>
<head><meta charset="utf-8"><title>vscode: auto-comment on newline · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html">vscode: auto-comment on newline</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201574238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574238">(Jun 22 2020 at 07:22)</a>:</h4>
<p>Kate (the KDE text editor) has a feature where when I hit Shift-Enter to start a new line, the next line starts with the same comment characters as the current one. That is really useful when writing longer comments or doc-comments, as I don't have to type <code>//</code> or <code>///</code> all the time. Is there a similar feature for vscode/rust-analyzer?</p>



<a name="201574308"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574308" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574308">(Jun 22 2020 at 07:23)</a>:</h4>
<p>Yes, you need to add a keybinding for the <code>onEnter</code> command</p>



<a name="201574353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574353">(Jun 22 2020 at 07:24)</a>:</h4>
<p>But it's a bit awkward if you're using the Vim extension</p>



<a name="201574373"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574373" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574373">(Jun 22 2020 at 07:24)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/4277#issuecomment-623075616">https://github.com/rust-analyzer/rust-analyzer/issues/4277#issuecomment-623075616</a></p>



<a name="201574532"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574532" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574532">(Jun 22 2020 at 07:26)</a>:</h4>
<p>Im not using the vim extension</p>



<a name="201574566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574566">(Jun 22 2020 at 07:27)</a>:</h4>
<p>I dont want this to happen on normal enter though, just on shift-enter or so</p>



<a name="201574604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574604">(Jun 22 2020 at 07:27)</a>:</h4>
<p>Ah, you might be able to add a binding for that (unless Shift-Enter is special)</p>



<a name="201574741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574741">(Jun 22 2020 at 07:29)</a>:</h4>
<p>hm, <code>editorLangId</code> is compared twice in that string...</p>



<a name="201574751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574751">(Jun 22 2020 at 07:29)</a>:</h4>
<p>ah no there's just missing parentheses</p>



<a name="201574807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574807">(Jun 22 2020 at 07:30)</a>:</h4>
<p>well, relying on <code>&amp;&amp;</code> binding stronger than <code>||</code> which is a form of code obfuscation ;)</p>



<a name="201574823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574823">(Jun 22 2020 at 07:30)</a>:</h4>
<p>that works, but it only works for doc comments</p>



<a name="201574829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574829">(Jun 22 2020 at 07:30)</a>:</h4>
<p>I also often write long non-doc comments and would like the same thing there</p>



<a name="201574831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574831">(Jun 22 2020 at 07:30)</a>:</h4>
<p>is that possible?</p>



<a name="201574834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574834">(Jun 22 2020 at 07:30)</a>:</h4>
<p>That's because brackets don't work in that attribute. It looks like a JS expression, but it's not.</p>



<a name="201574965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574965">(Jun 22 2020 at 07:32)</a>:</h4>
<p>Yeah, it seems like it doesn't work for normal comments, not sure why. It might have been removed at some point.</p>



<a name="201574988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201574988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201574988">(Jun 22 2020 at 07:33)</a>:</h4>
<p>The workaround is to write them as doc comments, then remove a column of slashes <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="201575003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201575003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201575003">(Jun 22 2020 at 07:33)</a>:</h4>
<p>ugh^^</p>



<a name="201575011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201575011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201575011">(Jun 22 2020 at 07:33)</a>:</h4>
<p>my workaround is to make a feature request :D</p>



<a name="201575018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/vscode%3A%20auto-comment%20on%20newline/near/201575018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/vscode.3A.20auto-comment.20on.20newline.html#201575018">(Jun 22 2020 at 07:33)</a>:</h4>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/issues/4980">https://github.com/rust-analyzer/rust-analyzer/issues/4980</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>